package 工厂模式.抽象工厂模式;

import 工厂模式.抽象工厂模式.factory.AppliancesFactory;
import 工厂模式.抽象工厂模式.factory.HairFactory;
import 工厂模式.抽象工厂模式.factory.HisenseFactory;
import 工厂模式.抽象工厂模式.product.AbstractFreezer;
import 工厂模式.抽象工厂模式.product.AbstractTV;

/**
 *  客户端
 */
public class Client {

    private AbstractTV tv;

    private AbstractFreezer freezer;

    public Client(AppliancesFactory factory){
        // 在客户端看来 就是使用抽象工厂来生产家电
        this.tv = factory.createTV();
        this.freezer = factory.createFreezer();
    }

    public AbstractTV getTv() {
        return tv;
    }

    public void setTv(AbstractTV tv) {
        this.tv = tv;
    }

    public AbstractFreezer getFreezer() {
        return freezer;
    }

    public void setFreezer(AbstractFreezer freezer) {
        this.freezer = freezer;
    }


    public static void main(String[] args) {
        Client client = new Client(new HairFactory());
        AbstractTV tv1 = client.getTv();
        System.out.println(tv1);
        AbstractFreezer freezer1 = client.getFreezer();
        System.out.println(freezer1);
    }
}
